//-----------------------------------------------------------------------
// <copyright file="RoleAssignmentCollection.cs" company="Alan Rodrigues">
//     Copyright (c) Alan Rodrigues. All rights reserved.
// </copyright>
// <developed>Alan Rodrigues (operninha@gmail.com)</developed>
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using Microsoft.Interop.Security.AzRoles;

namespace Authorization
{
    /// <summary>
    ///  <see cref="RoleDefinition"/> collection
    /// </summary>
    public class RoleDefinitionCollection : System.Collections.ObjectModel.Collection<RoleDefinition> 
    {
        /// <summary>
        /// default constructor
        /// </summary>
        public RoleDefinitionCollection()
        {                        
        }

        public RoleDefinitionCollection(IList<RoleDefinition> list)
            : base(list)
        { 
        }

        ///// <summary>
        /////  Initializes a instance of the RoleCollection class that is empty and has the specified initial capacity
        ///// </summary>
        ///// <param name="capacity">The number of elements that new list can initially store</param>
        //public RoleCollection(int capacity)
        //    : base(capacity)
        //{
        //}

        /// <summary>
        ///  Construtor
        /// </summary>
        /// <param name="application"><see cref="Application"/> associada ao <see cref="Role"/></param>
        /// <param name="azRoleDefinitions">RoleCollection do AzMan</param>
        internal RoleDefinitionCollection(Application application, IAzRoleDefinitions azRoleDefinitions,  string scopeName)
        {
            if (azRoleDefinitions == null)
            {
                throw new ArgumentNullException("azRoleDefinitions");
            }
            
            
            foreach (IAzRoleDefinition azRoleDefinition in azRoleDefinitions)
            {
                Add(new RoleDefinition(application, azRoleDefinition, scopeName));
            }
        }

        //public void AddRange(RoleCollection roles)
        //{
        //    for (int roles = 0; roles < length; roles++)
        //    {
                
        //    }
        //}
        /// <summary>
        ///  Lista dos Nomes dos <see cref="RoleCollection"/>
        /// </summary>
        /// <returns>Array de String com os names dos <see cref="RoleCollection"/></returns>
        public string[] Names()
        {
            var names = new string[Count];

            for (var i = 0; i < Count; i++)
                names[i] = this[i].Name;

            return names;
        }
     }
}